package com.thread.demo.thread;

public class ThreadTest {

    public static void main(String[] args) {
        class MyThread extends Thread{
            private int ticket = 10;
            @Override
            public void run() {
                for(int i=0; i < 20; i++) {
                    if(this.ticket>0) {
                        System.out.println(Thread.currentThread().getName() + "买票：ticket" + ticket--);
                    }
                }
            }
        }
        MyThread thread1 = new MyThread();
        MyThread thread2 = new MyThread();
        MyThread thread3 = new MyThread();
        thread1.start();
        thread2.start();
        thread3.start();
    }
}
